function isHuiWen(str) {
  let end = str.length;
  if (end == 0 || end == 1) return true;
  let start = 0;
  end--;
  while (start < end) {
    if (str[start] !== str[end]) return false;
    start++;
    end--;
  }
  return true;
  // return str.split("").reverse().join("") == str;
}
console.log(isHuiWen("112"));
function getMaxHuiWen(str) {
  let end = str.length;
  if (str.length == 0 || str.length == 
    1) return str;

  let ret = "";
  let count = 0;
  while (end >= 2) {
    for (let i = 0; i < end; i++) {
      if (str[i] !== str[end - 1]) continue;
      let nStr = str.slice(i, end);
      let len = nStr.length;
      if (len <= count) break;
      if (isHuiWen(nStr)) {
        count = len;
        ret = nStr;
        break;
      }
    }
    end--;
  }
  return ret;
}

console.log(
  getMaxHuiWen(
    "kyyrjtdplseovzwjkykrjwhxquwxsfsorjiumvxjhjmgeueafubtonhlerrgsgohfosqssmizcuqryqomsipovhhodpfyudtusjhonlqabhxfahfcjqxyckycstcqwxvicwkjeuboerkmjshfgiglceycmycadpnvoeaurqatesivajoqdilynbcihnidbizwkuaoegmytopzdmvvoewvhebqzskseeubnretjgnmyjwwgcooytfojeuzcuyhsznbcaiqpwcyusyyywqmmvqzvvceylnuwcbxybhqpvjumzomnabrjgcfaabqmiotlfojnyuolostmtacbwmwlqdfkbfikusuqtupdwdrjwqmuudbcvtpieiwteqbeyfyqejglmxofdjksqmzeugwvuniaxdrunyunnqpbnfbgqemvamaxuhjbyzqmhalrprhnindrkbopwbwsjeqrmyqipnqvjqzpjalqyfvaavyhytetllzupxjwozdfpmjhjlrnitnjgapzrakcqahaqetwllaaiadalmxgvpawqpgecojxfvcgxsbrldktufdrogkogbltcezflyctklpqrjymqzyzmtlssnavzcquytcskcnjzzrytsvawkavzboncxlhqfiofuohehaygxidxsofhmhzygklliovnwqbwwiiyarxtoihvjkdrzqsnmhdtdlpckuayhtfyirnhkrhbrwkdymjrjklonyggqnxhfvtkqxoicakzsxmgczpwhpkzcntkcwhkdkxvfnjbvjjoumczjyvdgkfukfuldolqnauvoyhoheoqvpwoisniv"
  )
);

// console.log(getMinHuiWen("qaha"));
